(function () {
    const t = document.createElement('link').relList;
    if (t && t.supports && t.supports('modulepreload')) return;
    for (const r of document.querySelectorAll('link[rel="modulepreload"]')) o(r);
    new MutationObserver((r) => {
        for (const i of r)
            if (i.type === 'childList')
                for (const f of i.addedNodes)
                    f.tagName === 'LINK' && f.rel === 'modulepreload' && o(f);
    }).observe(document, { childList: !0, subtree: !0 });
    function n(r) {
        const i = {};
        return (
            r.integrity && (i.integrity = r.integrity),
            r.referrerPolicy && (i.referrerPolicy = r.referrerPolicy),
            r.crossOrigin === 'use-credentials'
                ? (i.credentials = 'include')
                : r.crossOrigin === 'anonymous'
                    ? (i.credentials = 'omit')
                    : (i.credentials = 'same-origin'),
            i
        );
    }
    function o(r) {
        if (r.ep) return;
        r.ep = !0;
        const i = n(r);
        fetch(r.href, i);
    }
})();
const s = 'object',
    l = 'array',
    c = (e) =>
        Object.prototype.toString
            .call(e)
            .replace('[object ', '')
            .replace(']', '')
            .toLowerCase(),
    p = (e) => !(c(e) === s || c(e) === l);
function u(e) {
    if (c(e) === l)
        e.forEach((t, n) => {
            p(t) ? (e[n] = c(t)) : u(t);
        });
    else if (c(e) === s)
        for (const t in e) {
            const n = e[t];
            p(n) ? (e[t] = c(n)) : u(e[t]);
        }
}
function m(e, t) {
    const n = e[t].map((r) => JSON.stringify(r)),
        o = [...new Set(n)].map((r) => JSON.parse(r));
    o.filter((r) => {
        if (c(r) === s) return a(r), !0;
    }),
        o.length > 1,
        (e[t] = o);
}
function a(e) {
    if (c(e) === s)
        for (const t in e) {
            const n = e[t];
            c(n) === l ? m(e, t) : c(n) === s && a(n);
        }
    else c(e) === l && (e = y(e));
}
function y(e) {
    console.log('obj', e);
    const t = e.map((o) => JSON.stringify(o));
    return [...new Set(t)].map((o) => JSON.parse(o));
}
function d(e) {
    return (
        u(e),
        a(e),
        c(e) === l && (e = y(e)),
        JSON.stringify(e).replaceAll("'", '').replaceAll('"', '').replaceAll('[', '').replaceAll(',', ',\n').replaceAll('{', '{\n').replaceAll('}', '\n}')
    );
}
function g(e) {
    var t = new Function('return ' + e)();
    return t;
}
document.addEventListener('DOMContentLoaded', function () {
    document.querySelector('#button').onclick = function () {
        let e = document.querySelector('#input').value;
        (e = g(e)),
            document.querySelector('#type').checked
                ? (this.value = 'type XXXX = ' + d(e))
                : (this.value = 'interface XXXX ' + d(e).replaceAll(',', ';'));
    };
});
